package edu.dayu.service.impl;

import edu.dayu.mapper.OrderInfoMapper;
import edu.dayu.service.OrderDubbo;
import edu.dayu.service.OrderService;
import edu.dayu.vo.order.OrderCountQueryVo;
import edu.dayu.vo.order.OrderCountVo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@DubboService
public class OrderDubboImpl implements OrderDubbo {

    @Autowired
    private OrderInfoMapper orderInfoMapper;

    @Override
    public Map<String, Object> getCountMap(OrderCountQueryVo orderCountQueryVo) {
        Map<String, Object> map = new HashMap<>();
        List<OrderCountVo> orderCountVoList
                = orderInfoMapper.selectOrderCount(orderCountQueryVo);
        //日期列表
        List<String> dateList
                =orderCountVoList.stream().map(OrderCountVo::getReserveDate).collect(Collectors.toList());
        //统计列表
        List<Integer> countList
                =orderCountVoList.stream().map(OrderCountVo::getCount).collect(Collectors.toList());
        map.put("dateList", dateList);
        map.put("countList", countList);
        return map;
    }
}
